(function($){
    $.fn.displayPeriod=function(o){
        var periods = o['periods'].split(";");
        
        var colorOn = "#fffed9";
        var colorOff = "#ddd400";
        
        var color = '';
        
        this.html('');
        
        for(var i=0;i<periods.length;i++){
            var period_working = periods[i].split(".");
            if(period_working[1] == 'W'){
                color = colorOn;
            } else if(period_working[1] == 'O'){
                color = colorOff;
            }
            var period = period_working[0].split("-");
            if(period.length == 2){
                this.append('<div id="'+this.attr('id')+'_period_'+i+'i">'+period[0]+'........</div>');
                this.append('<div id="'+this.attr('id')+'_period_'+i+'f">'+period[1]+'</div>');
                $('#'+this.attr('id')+'_period_'+i+'i').css('background-color',color);
                $('#'+this.attr('id')+'_period_'+i+'f').css('background-color',color);
            } else {
                this.append('<div id="'+this.attr('id')+'_period_'+i+'i">'+period[0]+'</div>');
                $('#'+this.attr('id')+'_period_'+i+'i').css('background-color',color);
            }
        }
        this.show();
    };
})(jQuery);